/*
 * FXGL - JavaFX Game Library. The MIT License (MIT).
 * Copyright (c) AlmasB (almaslvl@gmail.com).
 * See LICENSE for details.
 */

package com.windea.study.kotlin.fxgl.sample.sandbox

import com.almasb.fxgl.dsl.*
import com.almasb.fxgl.dsl.components.*
import com.almasb.fxgl.entity.*
import javafx.scene.paint.*
import javafx.scene.shape.*
import javafx.util.*

/**
 * @author Almas Baimagambetov (almaslvl@gmail.com)
 */
class MyEntityFactory : EntityFactory {
	
	@Spawns("r,rect,type1")
	fun newRectangle(data: SpawnData): Entity {
		return FXGL.entityBuilder()
			.from(data)
			.view(Rectangle(30.0, 30.0))
			.build()
	}
	
	@Spawns("")
	fun newEmpty(data: SpawnData): Entity {
		return FXGL.entityBuilder()
			.from(data)
			.view(Rectangle(30.0, 30.0, Color.RED))
			.build()
	}
	
	@Spawns("c,circle,type2,type3")
	fun newCircle(data: SpawnData): Entity {
		return FXGL.entityBuilder()
			.from(data)
			.view(Circle(15.0))
			.build()
	}
	
	@Spawns("Wall,Player,Coin")
	fun newObjectgid(data: SpawnData): Entity {
		return FXGL.entityBuilder()
			.from(data)
			.with(KeepOnScreenComponent().onlyHorizontally())
			.with(ExpireCleanComponent(Duration.seconds(3.0)))
			.build()
	}
}
